package me.zk.practice1.sort;

import java.util.Arrays;

/**
 * @author zhangkai
 * @date 2023/7/30 10:31
 */
public class Sort2 {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(sort(new int[]{2,3,1,9,5,3})));
    }
    public static int[] sort(int[] nums) {

        for (int i = 0; i < nums.length; i++) {
            int min = nums[i];
            int index = i;
            for (int j = i; j < nums.length; j++) {
                if (min > nums[j]) {
                    index = j;
                    min = nums[j];
                }
            }
            if (index != i) {
                swap(nums,i,index);

            }
        }
        return nums;

    }
    public static void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;

    }

}
